/**
  ******************************************************************************
  * @file    CM_TypeDef.h
  * @author  DLSVN_Intern1
  * @version 
  * @date    14-July-2012
  * @brief   This file provide a definition for data type
  *          Reference <stdint.h> from IAR Library, this definition may be 
  *			 different from each compiler
  ******************************************************************************
*/
 
/*******************************************************************************
 * 								IMPORT
 ******************************************************************************/


/*******************************************************************************
 * 								DEFINE
 ******************************************************************************/

/************************************ GLOBAL DEFINE ****************************/
#ifndef CM_TYPEDEF_H
#define CM_TYPEDEF_H

#include <stdint.h>

//#ifndef int32_t
//    #define uint8_t     unsigned char
//    #define int8_t      signed char
//    #define uint16_t    unsigned short
//    #define int16_t     short
//    #define uint32_t    unsigned long
//    #define int32_t     long
//    #define uint64_t    unsigned long long
//    #define int64_t     long long
//#endif
//
#ifndef BOOL
    #define BOOL        unsigned char
#endif
    
#ifndef FALSE
    #define FALSE   (uint8_t)0
    #define TRUE    (uint8_t)1
#endif
#define NUMBERSLAVE (uint32_t)32


#ifdef USE_STM3210E_EVAL
/**********************   @ Define: LED PIN, LED PORT *************************/
    #define PORT_LED        PORTF
    #define PIN_LED1        GPIO_PIN_6
    #define PIN_LED2        GPIO_PIN_7
    #define PIN_LED3        GPIO_PIN_8
    #define PIN_LED4        GPIO_PIN_9

/*********************   @ Define: BUTTON PIN, BUTTON PORT ********************/
    
    #define PORT_JOY_SEL    PORTG
    #define PIN_JOY_SEL     GPIO_PIN_7
    #define PORT_JOY_DOWN   PORTD
    #define PIN_JOY_DOWN    GPIO_PIN_3
    #define PORT_JOY_LEFT   PORTG
    #define PIN_JOY_LEFT    GPIO_PIN_14
    #define PORT_JOY_RIGHT  PORTG
    #define PIN_JOY_RIGHT   GPIO_PIN_13
    #define PORT_JOY_UP     PORTG
    #define PIN_JOY_UP      GPIO_PIN_15
    #define PORT_TAMPER     PORTC
    #define PIN_TAMPER      GPIO_PIN_13
    #define PORT_WAKEUP     PORTA
    #define PIN_WAKEUP      GPIO_PIN_0
    #define PORT_KEY        PORTG
    #define PIN_KEY         GPIO_PIN_8

/********************   @ Define: UART PIN, UART PORT *************************/
    
    #define UART1_GPIO_TX   GPIOA
    #define UART1_PIN_TX    GPIO_PIN_9
    #define UART1_GPIO_RX   GPIOA
    #define UART1_PIN_RX    GPIO_PIN_10
    
    #define UART2_GPIO_TX   GPIOA
    #define UART2_PIN_TX    GPIO_PIN_2
    #define UART2_GPIO_RX   GPIOA
    #define UART2_PIN_RX    GPIO_PIN_1

    #define UART1_RTS_GPIO_PORT    GPIOD
    #define UART1_RTS_PIN          GPIO_PIN_4
    #define UART2_RTS_GPIO_PORT    GPIOA
    #define UART2_RTS_PIN          GPIO_PIN_1  

    #define UART1_BAUDRATE   115200
    #define UART1_DATABITS   USART_WordLength_8b
    #define UART1_STOPBITS   USART_StopBits_1
    #define UART1_PARITY     USART_Parity_No
    
    #define UART2_BAUDRATE   115200
    #define UART2_DATABITS   USART_WordLength_8b
    #define UART2_STOPBITS   USART_StopBits_1
    #define UART2_PARITY     USART_Parity_No

    #define TX_BUFFER_SIZE1  100
    #define RX_BUFFER_SIZE1  100
    #define TX_BUFFER_SIZE2  100
    #define RX_BUFFER_SIZE2  100
#endif

#ifdef USE_STM3210B_EVAL

/*********************   @ Define: LED PIN, LED PORT **************************/

    #define PORT_LED        PORTC
    #define PIN_LED1        GPIO_PIN_6
    #define PIN_LED2        GPIO_PIN_7
    #define PIN_LED3        GPIO_PIN_8
    #define PIN_LED4        GPIO_PIN_9
    
/********************   @ Define: BUTTON PIN, BUTTON PORT *********************/
    
    #define PORT_JOY_SEL    PORTD
    #define PIN_JOY_SEL     GPIO_PIN_12
    #define PORT_JOY_DOWN   PORTD
    #define PIN_JOY_DOWN    GPIO_PIN_14
    #define PORT_JOY_LEFT   PORTE
    #define PIN_JOY_LEFT    GPIO_PIN_1
    #define PORT_JOY_RIGHT  PORTE
    #define PIN_JOY_RIGHT   GPIO_PIN_0
    #define PORT_JOY_UP     PORTD
    #define PIN_JOY_UP      GPIO_PIN_8
    #define PORT_TAMPER     PORTC
    #define PIN_TAMPER      GPIO_PIN_13
    #define PORT_WAKEUP     PORTA
    #define PIN_WAKEUP      GPIO_PIN_0
    #define PORT_KEY        PORTB
    #define PIN_KEY         GPIO_PIN_9
    
/*******************   @ Define: UART PIN, UART PORT **************************/  
    
    #define UART1_GPIO_TX   GPIOA
    #define UART1_PIN_TX    GPIO_PIN_9
    #define UART1_GPIO_RX   GPIOA
    #define UART1_PIN_RX    GPIO_PIN_10
    
    #define UART2_GPIO_TX   GPIOD
    #define UART2_PIN_TX    GPIO_PIN_5
    #define UART2_GPIO_RX   GPIOD
    #define UART2_PIN_RX    GPIO_PIN_6

    #define UART1_RTS_GPIO_PORT    GPIOD
    #define UART1_RTS_PIN          GPIO_PIN_4
    #define UART2_RTS_GPIO_PORT    GPIOA
    #define UART2_RTS_PIN          GPIO_PIN_1  
    
    #define UART1_BAUDRATE   115200
    #define UART1_DATABITS   USART_WordLength_8b
    #define UART1_STOPBITS   USART_StopBits_1
    #define UART1_PARITY     USART_Parity_No
    
    #define UART2_BAUDRATE   115200
    #define UART2_DATABITS   USART_WordLength_8b
    #define UART2_STOPBITS   USART_StopBits_1
    #define UART2_PARITY     USART_Parity_No  

    #define TX_BUFFER_SIZE1  100
    #define RX_BUFFER_SIZE1  100
    #define TX_BUFFER_SIZE2  100
    #define RX_BUFFER_SIZE2  100
#endif


/*********************************CAN CONFIG***********************************/

#define ID11bit         0x00
#define ID29bit         0x01

#define MyTypeID        ID11bit
#define MyID            0x123
#define MyDataLength    8

/* Define the STM32F10x hardware depending on the used evaluation board */
#ifdef USE_STM3210B_EVAL
  #define RCC_APB2Periph_GPIO_CAN1    RCC_APB2Periph_GPIOD
  #define GPIO_Remapping_CAN1         GPIO_Remap2_CAN1
  #define GPIO_CAN1                   GPIOD  
  #define GPIO_Pin_CAN1_RX            GPIO_Pin_0
  #define GPIO_Pin_CAN1_TX            GPIO_Pin_1

#elif USE_STM3210E_EVAL
  #define RCC_APB2Periph_GPIO_CAN1    RCC_APB2Periph_GPIOB
  #define GPIO_Remapping_CAN1         GPIO_Remap1_CAN1
  #define GPIO_CAN1                   GPIOB
  #define GPIO_Pin_CAN1_RX            GPIO_Pin_8
  #define GPIO_Pin_CAN1_TX            GPIO_Pin_9
#endif /* USE_STM3210B_EVAL */


#endif
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/*********************************END OF FILE**********************************/

